<%

Sub User_Add()	

	Dim useranme,password,Super,Lock
	
	username = reform("username")
	password = reform("password")
	Super	 = reform("Super")
	lock	 = reform("lock")	


	sql = "SELECT * FROM Admin_User WHERE Admin_UserName = '" & username & "'"
	Set rs = conn.execute(sql)


	If Not rs.Eof Then

		AlertBox "用户名已经存在!","javascript:history.go(-1)"	

	End If

	rs.close

	sql = "INSERT INTO Admin_User(Admin_UserName,Admin_Password,Admin_UseFlag,Admin_SuperUser) VALUES( " &_
		  "'" & username & "'" &_
		  ",'" & md5(password) & "'" &_
		  ",'" & lock & "'" &_
		  ",'" & Super & "')" 

    conn.execute(sql)

	AlertBox "用户增加成功！","User_Query.asp"


End Sub

Sub User_Edit()	

	Dim useranme,password,Super,Lock,UserID
	
	username = reform("username")
	password = reform("password")
	Super	 = reform("Super")
	lock	 = reform("lock")	

	UserID = reform("UserID")	

	If password="" Then
		sql = "UPDATE Admin_User Set " &_
			  " Admin_UserName = '" & username & "'" &_
			  ",Admin_UseFlag   = '" & lock & "'" &_
			  ",Admin_SuperUser = '" & Super & "' " &_
			  " WHERE Admin_UserID = "&UserID
	Else
		sql = "UPDATE Admin_User Set " &_
			  " Admin_UserName = '" & username & "'" &_
			  ",Admin_Password = '" & md5(password) & "'" &_
			  ",Admin_UseFlag   = '" & lock & "'" &_
			  ",Admin_SuperUser = '" & Super & "' " &_
			  " WHERE Admin_UserID = "&UserID

	End If

    conn.execute(sql)
	AlertBox "用户修改成功！","User_Query.asp"

End Sub

Sub User_Del()

	Dim UserID

	UserID = requery("Admin_UserID")	

	sql = "DELETE FROM  Admin_User WHERE Admin_UserID = "&UserID


    conn.execute(sql)

	AlertBox "用户删除成功！","User_Query.asp"
	
End Sub

Sub Get_User_Info(UserID)
	sql = "SELECT * FROM Admin_User WHERE Admin_UserID = " &UserID

	Set rs = conn.execute(sql)
	
	If Not rs.eof Then
		useranme = rs("Admin_UserName")
		password = rs("Admin_Password")
		Super	 = rs("Admin_SuperUser")
		lock	 = rs("Admin_UseFlag")	
	End If
	
	password = ""

	Call conn_close()

End Sub 
%>
